<template>
	<view>
		<view class="header status_bar" :class="scrrol == true ? 'scrrolHeader' : ''">
			<view class="back iconfont icon-xiangzuo1" @tap="backPage"></view>
			<view class="text" :class="scrrol == true ? 'scrrolHeader' : ''">填写信息</view>
		</view>	
		<view class="clear_box"></view>
		
		<view class="details_box">
			<view class="list">
				<view class="name">联系人</view>
				<input type="text" v-model="name" value="" placeholder="请输入签约人真实姓名" />
			</view>
			<view class="list">
				<view class="name">联系方式</view>
				<view class="radio_box">
					<radio-group @change="radioChange">
						<label class="radio">
							<radio color="#FF7701" value="1" checked="true" />手机
						</label>
						<label class="radio">
							<radio color="#FF7701" value="2" />邮箱
						</label>
					</radio-group>
				</view>
			</view>
			<view class="list" v-if="contact_type == 1">
				<view class="name">手机号码</view>
				<input type="text" v-model="phone" value="" placeholder="请输入手机号" />
			</view>
			<view class="list" v-if="contact_type == 2">
				<view class="name">邮箱</view>
				<input type="text" v-model="phone" value="" placeholder="请输入邮箱" />
			</view>
			<view class="list">
				<view class="name">微信号</view>
				<input type="text" v-model="wechat" value="" placeholder="请输入微信号" />
			</view>
			<view class="list">
				<view class="name">企业名称</view>
				<input type="text" v-model="tenant_name" value="" placeholder="请输入企业名称" />
			</view>
			
		</view>
		
		<view class="confirm" @tap="save">保存并返回</view>
		
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				page:1,
				scrrol:false,
				name:'',
				phone:'',
				wechat:'',
				contact_type:1,
				tenant_name:'',
				id:0,
			}
		},
		onLoad() {
			let that = this;
			that.loadAddress();
		},
		methods: {
			loadAddress(){
				let that = this;
				that.Net._get('auth/order/address', {}, res => {
					if (res.code == 200) {
						if (res.data){
							that.name = res.data.contract_name;
							that.phone = res.data.phone;
							that.wechat = res.data.wechat;
							that.tenant_name = res.data.tenant_name;
							that.contact_type = res.data.contact_type;
							that.id = res.data.address_id;
						}
					}
				});
			},
			radioChange(e){
				let that = this;
				console.log(e.detail.value);
				that.contact_type = e.detail.value;
			},
			save() {
				let that = this;
				if (!that.tenant_name || !that.name || !that.phone){
					that.Msg.Fail('请填写内容');
					return;
				}
				let data = {
					id:that.id,
					tenant_name:that.tenant_name,
					contract_name:that.name,
					phone:that.phone,
					wechat:that.wechat,
					contact_type:that.contact_type,
				};
				that.Net._post('auth/order/up_address',data, res => {
					if (res.code == 200) {
						uni.setStorageSync('coupon_load', 1);
						that.Msg.Success('保存成功', res => {
							uni.navigateBack({});
						});
					}
				});
			},
			backPage() {
				uni.navigateBack({});
			},
			gotopage(e) {
				let url = e.currentTarget.dataset.url;
				uni.navigateTo({
					url: url
				});
			},

		},
		onPageScroll: function(Object) {
			//console.log(Object.scrollTop); //实时获取到滚动的值
			if (Object.scrollTop > 28) {
				this.scrrol = true;
				/* #ifdef APP-PLUS */
				/* #endif */
			} else if (Object.scrollTop < 28) {
				this.scrrol = false;
				/* #ifdef APP-PLUS */
				/* #endif */
			}
		},
		onReachBottom() {
		  var that = this;
		  that.page++;
		  // that.Net._get('shop_goods', {per_page:'10',page:that.page,}, res => {
		  //   if (res.code == 200) {
		  //     //console.log(res)
		  //     if (res.data.data == '') {
		  //       uni.showToast({
		  //         title: '已经是最后一页了',
		  //         duration: 2000,
		  //         icon: 'none'
		  //       });
		  //     } else {
		  //       that.info = that.info.concat(res.data.data); //将数据拼接在一起
		  //     }
		  //   } else if (res.code == 0) {
		  //     that.Msg.Success(res.msg, res => {});
		  //   }
		  // });
		},
	}
</script>

<style>
	
	
	.scrrolHeader{
		background-color: #FF7701 !important;
	}
	
	.details_box {
		width: 92%;
		margin: 4% auto 0;
		background-color: #fff;
		padding: 5vw 4%;
		border-radius: 3vw;
	}
	
	.details_boxNo{
		padding: 0vw 4%;
	}
	
	.details_box .details_title {
		font-size: 4.2vw;
		color: #333;
		font-weight: bold;
		margin-bottom: 5vw;
	}
	
	.details_box .input_box{
		width: 100%;
		display: flex;
		align-items: center;
		border-bottom: 2px solid #FC5D20;
		height: 15vw;
	}
	
	.details_box .input_box .m{
		font-size: 4vw;
		color: #333;
		margin-right: 1vw;
		font-weight: bold;
		margin-top: 2vw;
	}
	
	.details_box .input_box input{
		font-size: 7vw;
		color: #333;
		flex: 1;
		font-weight: bold;
	}
	
	.details_box .list {
		width: 100%;
		padding: 5vw 0;
		border-bottom: 1px solid #F3F3F3;
		display: flex;
		align-items: center;
		position: relative;
	}
	
	.details_box .list .name {
		font-size: 4.2vw;
		font-weight: bold;
		color: #333;
		margin-right: 4vw;
	}
	
	.details_box .list .text {
		flex: 1;
		font-size: 3.5vw;
		color: #333;
		margin-right: 1vw;
		font-weight: bold;
		display: flex;
		align-items: center;
		justify-content: flex-end;
	}
	
	.details_box .list .text .i{
		width: 5vw;
		margin-right: 1vw;
	}
	
	.details_box .list .text .i image{
		width: 100%;
	}
	
	.details_box .list input {
		flex: 1;
		font-size: 3.5vw;
		color: #333;
		margin-right: 3vw;
		text-align: right;
		font-weight: bold;
	}
	
	.details_box .list .arrow {
		font-size: 3.5vw;
		color: #333;
	}
	
	.details_box .list .yzm {
		font-size: 3.5vw;
		color: #FC5D20;
		font-weight: bold;
		outline: none;
		background-color: transparent !important;
		border-radius: 10vw;
		height: 10vw;
		border: 1px solid #FC5D20;
	}
	
	.standing{
		width: 100%;
	}
	
	.standing image{
		width: 100%;
	}
	
	.standing .text{
		width: 100%;
		font-size: 3.8vw;
		color: #333;
		font-weight: bold;
		margin-top: 3vw;
		text-align: center;
	}
	
	.details_box .standing:nth-child(2){
		margin-top: 5vw;
	}
	
	.details_box .list .radio_box{
		flex: 1;
		display: flex;
		align-items: center;
		justify-content: flex-end;
	}
	
	.details_box .list .radio_box .radio{
		margin-left: 3vw;
	}
	
	.details_box .list .radio_box .radio radio{
		font-size: 3.5vw;
	}
	
	
	
</style>
